﻿using System;
using System.Collections.Generic;
using System.Data.Entity;

namespace FantasyDraft2.Models
{
    public class SampleData : DropCreateDatabaseAlways<FantasyDraftEntities>
    {
        protected override void Seed(FantasyDraftEntities context)
        {
            var player = new List<Player>
                {
                    // Provide values for any properties of Player as nessecary. Leaving an ID field blank will auto increment the field.

                    /*NOTE: The firs two sections (which explicity fill the 2 User's teams) have a player ID assigned to them.  This is because these two teams
                     will be initialized every time the program starts so that the 2 teams will always be filled.  After instantiating the players for the 2 known teams,
                     the PlayerId assignment will be excluded such that it will auto-increment. -Ako*/

                    //List of Active Players for User(Team) 1
                    new Player {PlayerId = 1, Name = "Arnold Barth", Goals = 12, Assists = 9, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 1},
                    new Player {PlayerId = 2, Name = "Carsten Baader", Goals = 3, Assists = 0, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 1},
                    new Player {PlayerId = 3, Name = "Bruno Baum", Goals = 3, Assists = 6, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 1},
                    new Player {PlayerId = 4, Name = "Manfred Eichel", Goals = 15, Assists = 3, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 1},
                    //User(Team 1) Benched Player
                    new Player {PlayerId = 5, Name = "Olof Daecher", Goals = 3, Assists = 0, IsActive = false, IsAvailable = false, IsInjured = false, TeamId = 1},

                    //List of Active Players for User(Team) 2
                    new Player {PlayerId = 6, Name = "Marius Engel", Goals = 0, Assists = 3, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 2},
                    new Player {PlayerId = 7, Name = "Philipp Faber", Goals = 9, Assists = 9, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 2},
                    new Player {PlayerId = 8, Name = "Rudolf Hueber", Goals = 3, Assists = 6, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 2},
                    new Player {PlayerId = 9, Name = "Wilhelm Gerber", Goals = 6, Assists = 0, IsActive = true, IsAvailable = false, IsInjured = false, TeamId = 2},
                    //User(Team 2) Benched Player
                    new Player {PlayerId = 10, Name = "Viktor Fried", Goals = 0, Assists = 3, IsActive = false, IsAvailable = false, IsInjured = false, TeamId = 2},

                    /*List of remaining 30 available, draftable players.*/
                    new Player {PlayerId = 11, Name = "Adam Conover", Goals = 30, Assists = 0, IsActive = false, IsAvailable = true, IsInjured = false}, //Lol
                    new Player {PlayerId = 12, Name = "Hans Gruber", Goals = 15, Assists = 5, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 13, Name = "Gunther Krebs", Goals = 4, Assists = 3, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 14, Name = "Steffen Jaeger", Goals = 2, Assists = 5, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 15, Name = "Wolfgang Koch", Goals = 6, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 16, Name = "Ingemar Keller", Goals = 0, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 17, Name = "Bruno Hanh", Goals = 2, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 18, Name = "Dolf Gruenewald", Goals = 5, Assists = 4, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 19, Name = "Euwald Fassbinder", Goals = 30, Assists = 0, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 20, Name = "Ludwig Metzger", Goals = 7, Assists = 4, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 21, Name = "Maximilian Lang", Goals = 0, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 22, Name = "Augustus Roth", Goals = 8, Assists = 2, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 23, Name = "Kurt Ptaff", Goals = 3, Assists = 0, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 24, Name = "Dagobert Saenger", Goals = 0, Assists = 5, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 25, Name = "Fabian Vogel", Goals = 2, Assists = 2, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 26, Name = "Konrad Unger", Goals = 10, Assists = 4, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 27, Name = "Theodor Amsel", Goals = 30, Assists = 0, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 28, Name = "Hartmut Gottschalk", Goals = 1, Assists = 7, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 29, Name = "Adolf Fiedler", Goals = 7, Assists = 4, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 30, Name = "Johann Goldschmidt", Goals = 9, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 31, Name = "Elias Thalberg", Goals = 0, Assists = 8, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 32, Name = "Axel Seiler", Goals = 15, Assists = 5, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 33, Name = "Lars Metzger", Goals = 4, Assists = 1, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 34, Name = "Bernhard Oster", Goals = 11, Assists = 7, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 35, Name = "Oskar Ackerman", Goals = 3, Assists = 3, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 36, Name = "Fabian Hertzog", Goals = 5, Assists = 2, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 37, Name = "Udo Sankt", Goals = 12, Assists = 4, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 38, Name = "Tobias Kaufmann", Goals = 30, Assists = 0, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 39, Name = "Jorg Zimmer", Goals = 1, Assists = 10, IsActive = false, IsAvailable = true, IsInjured = false},
                    new Player {PlayerId = 40, Name = "Golo Diederich", Goals = 6, Assists = 3, IsActive = false, IsAvailable = true, IsInjured = false}

                };
            player.ForEach(p => context.Players.Add(p));

            var user = new List<User>
                {
                    /*Initialization of Users.  There will only be two User's that will be added to the database upon starting the application. The rest will be created during
                     the demonstration. Also note that the score of each user must match the total sum of Goals + Assists for each player that was instantiated above.*/
                    new User {UserId = 1, UserName = "AkoCham", Password = "user1", FirstName = "Ako", LastName = "Cham", Age = 23, TeamId = 1, Score = 51, Birthdate = new DateTime(1989, 7, 23), DateOfFormation = new DateTime(2012, 12, 6), TeamName = "xXxHandballSlayerzxXx" },
                    new User {UserId = 2, UserName = "StrongGuy1", Password = "user2", FirstName = "Zidane", LastName = "Tribal", Age = 22, TeamId = 2, Score = 30, Birthdate = new DateTime(1990, 9, 5), DateOfFormation = new DateTime(2012, 12, 7), TeamName = "H4ndb4ll4Lyf3" },
               };
            user.ForEach(u => context.Users.Add(u));

            var playerGame = new List<PlayerGame>
                {
                    /*Initialization of PlayerGames.  A total of 3 games will be added for each player with a known PlayerId.  When creating the 3 games for each player, their goals and assists
                     across all games must match their total goals and assists. Keep in mind that the player's score for any given game will only impact the user's overall score if that player's 
                     "isActive" flag is set to true (meaning that they were not benched during that game).*/

                    /*GAMES FOR USER(TEAM) 1*/
                    //PlayerId 1 games.  Goals:12  Assists:9
                    new PlayerGame {Goals = 4, Assists = 3, PlayerId = 1, GameId = 1, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 4, Assists = 3, PlayerId = 1, GameId = 2, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 4, Assists = 3, PlayerId = 1, GameId = 3, TeamId = 1, isActive = true},
                    //PlayerId 2 games.  Goals:3 Assists:0
                    new PlayerGame {Goals = 0, Assists = 0, PlayerId = 2, GameId = 1, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 3, Assists = 0, PlayerId = 2, GameId = 2, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 0, Assists = 0, PlayerId = 2, GameId = 3, TeamId = 1, isActive = true},
                    //PlayerId 3 games.  Goals:3 Assists:6
                    new PlayerGame {Goals = 1, Assists = 3, PlayerId = 3, GameId = 1, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 1, Assists = 0, PlayerId = 3, GameId = 2, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 1, Assists = 3, PlayerId = 3, GameId = 3, TeamId = 1, isActive = true},
                    //PlayerId 4 games.  Goals:15 Assists:3
                    new PlayerGame {Goals = 6, Assists = 0, PlayerId = 4, GameId = 1, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 3, Assists = 3, PlayerId = 4, GameId = 2, TeamId = 1, isActive = true},
                    new PlayerGame {Goals = 6, Assists = 0, PlayerId = 4, GameId = 3, TeamId = 1, isActive = true},
                    //PlayerId 5 games.  Goals:3 Assists:0
                    new PlayerGame {Goals = 1, Assists = 0, PlayerId = 5, GameId = 1, TeamId = 1, isActive = false},
                    new PlayerGame {Goals = 1, Assists = 0, PlayerId = 5, GameId = 2, TeamId = 1, isActive = false},
                    new PlayerGame {Goals = 1, Assists = 0, PlayerId = 5, GameId = 3, TeamId = 1, isActive = false},

                    //PlayerId 6 games. Goals:0 Assists:3
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 6, GameId = 1, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 6, GameId = 2, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 6, GameId = 3, TeamId = 2, isActive = true},
                    //PlayerId 7 games.  Goals:3 Assists:9
                    new PlayerGame {Goals = 0, Assists = 3, PlayerId = 7, GameId = 1, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 3, Assists = 3, PlayerId = 7, GameId = 2, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 0, Assists = 3, PlayerId = 7, GameId = 3, TeamId = 2, isActive = true},
                    //PlayerId 8 games.  Goals:3 Assists:6
                    new PlayerGame {Goals = 1, Assists = 3, PlayerId = 8, GameId = 1, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 1, Assists = 0, PlayerId = 8, GameId = 2, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 1, Assists = 3, PlayerId = 8, GameId = 3, TeamId = 2, isActive = true},
                    //PlayerId 9 games.  Goals:6 Assists:0
                    new PlayerGame {Goals = 2, Assists = 0, PlayerId = 9, GameId = 1, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 2, Assists = 0, PlayerId = 9, GameId = 2, TeamId = 2, isActive = true},
                    new PlayerGame {Goals = 2, Assists = 0, PlayerId = 9, GameId = 3, TeamId = 2, isActive = true},
                    //PlayerId 10 games.  Goals:0 Assists:3
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 10, GameId = 1, TeamId = 2, isActive = false},
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 10, GameId = 2, TeamId = 2, isActive = false},
                    new PlayerGame {Goals = 0, Assists = 1, PlayerId = 10, GameId = 3, TeamId = 2, isActive = false},
                };
            playerGame.ForEach(g => context.PlayerGames.Add(g));

            var game = new List<Game>
                {
                /*Initialization of Games.  Please remember that these represent fantasy matchups between Users, not official team handball games. Therefore, since 3 games are initially seeded
                 to the database, it's important that the scores match the player's stats for the games they participated in. That is, the Score1 for GameId1 should be the sum of all Goals + Assists
                 of the players on TeamId1 who's GameId is 1 and who are active etc..*/
                new Game {GameId = 1, TeamId1 = 1, TeamId2 = 2, Score1 = 17, Score2 = 10},
                new Game {GameId = 2, TeamId1 = 1, TeamId2 = 2, Score1 = 17, Score2 = 10},
                new Game {GameId = 3, TeamId1 = 1, TeamId2 = 2, Score1 = 17, Score2 = 10},
            };
            game.ForEach(g => context.Games.Add(g));

            var playerComment = new List<PlayerComment>
                {
                /*Initialization of comments for players.  Out of the 10 players initialized and on teams (meaning they have ID numbers associated with them), one comment will be given. 
                 * All player comments added will have the CommentId field left blank such that it will auto-increment, these comments can still be found by the PlayerId field as it references 
                 * a specific player.*/

                //Comments for Initial players on User 1's fantasy team (Ids 1-5)
                new PlayerComment {PlayerId = 1, Comment = "Always a safe pick every year!"},
                new PlayerComment {PlayerId = 2, Comment = "How did he miss that goal last game?! HUEHUEHUE"},
                new PlayerComment {PlayerId = 3, Comment = "A great addition to any team. Ja."},
                new PlayerComment {PlayerId = 4, Comment = "Wouldn't start a league without this player."},
                new PlayerComment {PlayerId = 5, Comment = "2/10 WOULD NOT DRAFT."},

                //Comments for Initial players on User 2's fantasy team (Ids 6-10)
                new PlayerComment {PlayerId = 6, Comment = "What is he thinking this season?!"},
                new PlayerComment {PlayerId = 7, Comment = "He used to live near me!!1!1"},
                new PlayerComment {PlayerId = 8, Comment = "I could play Handball better than this jabroni!"},
                new PlayerComment {PlayerId = 9, Comment = "Whoever drafts him is lucky!"},
                new PlayerComment {PlayerId = 10, Comment = "I feel sorry for whoever drafts him lol"},

                //Comments for additional 30 players that are not yet drafted (Ids 11-40)
                new PlayerComment {PlayerId = 11, Comment = "ALL TIME ULTIMATE PLAYER."},
                new PlayerComment {PlayerId = 12, Comment = "Would have been better if he was never traded."},
                new PlayerComment {PlayerId = 13, Comment = "One of handball's finest."},
                new PlayerComment {PlayerId = 14, Comment = "He's not as good as he used to be."},
                new PlayerComment {PlayerId = 15, Comment = "His last game was very impressive."},
                new PlayerComment {PlayerId = 16, Comment = "This player is at the top of many draft lists."},
                new PlayerComment {PlayerId = 17, Comment = "This player hasn't played the same since his injury."},
                new PlayerComment {PlayerId = 18, Comment = "He's still new and needs to improve."},
                new PlayerComment {PlayerId = 19, Comment = "Perhaps he would be better at football."},
                new PlayerComment {PlayerId = 20, Comment = "All-time favorite player."},
                new PlayerComment {PlayerId = 21, Comment = "He's seems to care more about the fame than the game."},
                new PlayerComment {PlayerId = 22, Comment = "This player has great potential."},
                new PlayerComment {PlayerId = 23, Comment = "Why does he even try anymore?"},
                new PlayerComment {PlayerId = 24, Comment = "He's improved greatly since last season."},
                new PlayerComment {PlayerId = 25, Comment = "He's should make a great bench player."},
                new PlayerComment {PlayerId = 26, Comment = "I hope he's available to draft when I need him."},
                new PlayerComment {PlayerId = 27, Comment = "Don't draft if you like winning."},
                new PlayerComment {PlayerId = 28, Comment = "I expect great things from this player this season."},
                new PlayerComment {PlayerId = 29, Comment = "He did great last season."},
                new PlayerComment {PlayerId = 30, Comment = "Great addition to any draft."},
                new PlayerComment {PlayerId = 31, Comment = "Not worth drafting this season."},
                new PlayerComment {PlayerId = 32, Comment = "Whoever drafts this player is pretty lucky."},
                new PlayerComment {PlayerId = 33, Comment = "He leads his team to victory often."},
                new PlayerComment {PlayerId = 34, Comment = "Not impressed with his performance."},
                new PlayerComment {PlayerId = 35, Comment = "This player has come a long way since university handball."},
                new PlayerComment {PlayerId = 36, Comment = "This player is the key to victory."},
                new PlayerComment {PlayerId = 37, Comment = "Wouldn't even think of drafting this player."},
                new PlayerComment {PlayerId = 38, Comment = "This player plays as if its natural."},
                new PlayerComment {PlayerId = 39, Comment = "He's a great team player."},
                new PlayerComment {PlayerId = 40, Comment = "He likes to party."},
            };
            playerComment.ForEach(p => context.PlayerComments.Add(p));

            var userComment = new List<UserComment>
                {
                /*Initialization of comments for users (fantasy teams).  Out of the 2 players initialized during startup, 3 comments will be given to each user.
                 The CommentId can always be left empty since it will auto-increment and the CommentId iteself is irrelevant in finding a single user's comment.  
                 * However, a UserId must always be stated as it ties with the user itself.*/

                //Comments for UserId = 1
                new UserComment {UserId = 1, Comment = "He wins the fantasy draft every single year.  He has to cheat!"},
                new UserComment {UserId = 1, Comment = "Playing against Ako is a great way to lose your money..."},
                new UserComment {UserId = 1, Comment = "His knowledge of Handball knows no bounds."},

                //Comments for UserId = 2
                new UserComment {UserId = 2, Comment = "You can tell this is his first year doing a fantasy draft LOL!"},
                new UserComment {UserId = 2, Comment = "What a dumb team name."},
                new UserComment {UserId = 2, Comment = "Who invited this guy?!"},
            };
            userComment.ForEach(u => context.UserComments.Add(u));
        }
    }
}